package com.example.demo.mapper;

import com.example.demo.pojo.entity.UserSupport;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserSupportMapper {
    @Select("select * from user_support where user_id=#{userId} and forum_id=#{forumId}")
    UserSupport getByUserIdAndForumId(Long userId, Long forumId);

    @Delete("delete from user_support where id=#{id}")
    void deleteById(Long id);

    @Insert("insert into user_support (user_id, forum_id, create_time) VALUES (#{userId},#{forumId},#{createTime})")
    void insert(UserSupport userSupport);

    @Select("select * from user_support where user_id=#{userId}")
    List<UserSupport> list(Long userId);

    @Select("select count(id) from user_support where forum_id=#{forumId}")
    Integer getUserSupportNumByForumId(Long forumId);
}
